﻿using System.ComponentModel;

namespace DoVuiKinhThanh
{
    using System;
    using System.Linq.Expressions;

    public class ViewModelBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        // Create the OnPropertyChanged method to raise the event 
        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }

        protected void OnPropertyChanged<T>(Expression<Func<T>> propertyExpression) {
            OnPropertyChanged((propertyExpression.Body as MemberExpression).Member.Name);
        }
    }
}
